<?php

namespace app\api\controller;

use app\common\controller\Api;
use think\Db;

class Buying extends Api
{

	protected $noNeedLogin = [];
	protected $noNeedRight = '*';

	/**
	 * 上级认购数
	 */
	public function super_subc_nums()
	{
		$uid = $this->auth->id;
		$nums = \app\api\controller\basics\Basics::instance()->buy_limit_nums($uid);
		$this->success("正常", ["nums" => $nums]);
	}

	/**
	 * 代理认购数(采购额度)
	 */
	public function person_subc_nums()
	{
		$uid = $this->auth->id;
		$con = 0;
		$where = "agid = " . $uid;
		$check = Db::table("fd_equip_buy_nums")
			->where($where)
			->count();
		if ($check) {
			$con = Db::table("fd_equip_buy_nums")->where($where)->value("nums");
		}
		$this->success("正常", ["nums" => $con]);
	}
}
